package com.bigevent.bigevent.anno.impl;

import com.bigevent.bigevent.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

/**
 * @author yangxudong
 * @description:
 * @date 2024/2/15 11:31
 */
public class StateValidation implements ConstraintValidator<State, String> {
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (!StringUtils.hasLength(s)) {
            return true;
        }
        if (ObjectUtils.nullSafeEquals("已发布", s) || ObjectUtils.nullSafeEquals("草稿", s)) {
            return true;
        }
        return false;
    }
}
